<!DOCTYPE html>
<html>
<head>      
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>国际期货通</title>
    <script src="js/mui.min.js"></script>
    <script src="js/common.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link href="css/own.css" rel="stylesheet"/>
</head>
<body> 
<!--弹出广告-->
<!--<div class="app_qj" id="app_qj" style="display: none;"></div>
<div class="app_tc" id="app_tc" style="display: none;">
		<div class="app_tc_bj">
			<img class="app_img1" src="images/app-g.png">
	        <i id="closebtn" class="app_img2"><img src="images/app_x.png"></i>
	        <div class="app_img3">
	        <a href="javascript:void(0);" id="partake"><img src="images/app_an.png" width="150px"></a>	        	
	    </div>
	</div>
</div>	--> 
<!--弹出广告 end-->
	<header class="mui-bar mui-bar-nav own-topbg"> 
		<a href="javascript:void(0);" id="toNews"><img src="images/news.png" id="newsimg"></a>
		<h1 id="nav-title" class="mui-title">操盘申请</h1>
		<!--<a href="#" class="top-tel" id="telBtn">客服热线</a>-->
		<a href="javascript:void(0)" class="top-tel" id="online">在线客服</a>
	</header>
	<nav class="navlist">
		<a class="" href="javascript:void(0);" id="quotationMain">
			<span class="mui-icon"><img src="images/0.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">行情交易</span>
		</a>
		<a class="navon" href="javascript:void(0);"  id="product">
			<span class="mui-icon"><img src="images/1.0.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">操盘申请</span>
		</a>
		<a href="javascript:void(0);"  id="information">
			<span class="mui-icon"><img src="images/4.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">资讯直播</span>
		</a>
		<a class="" id="account" href="javascript:void(0);">
			<span class="mui-icon"><img src="images/3.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label" >账户</span>
		</a>
	</nav>
	<div class="mui-content own-mainlist" style="position: relative; top: -4px;">
		<div class="mui-slider" id="slider">
		  	<div class="mui-slider-group mui-slider-loop" id="bannerloop" >
		  		<div class="mui-slider-item" ><a href="javascript:void(0);"><img src="images/banner_load.jpg"/></a></div>
		  	</div>
		  	<div class="mui-slider-indicator" id="indicatorid">
				<!--<div class="mui-indicator mui-active"></div>
				<div class="mui-indicator"></div>
				<div class="mui-indicator"></div>
				<div class="mui-indicator"></div>-->
			</div>
		</div>
		<div class="futureTitle">国际期货推荐</div>
		<ul id="list" class="mui-table-view mui-table-view-chevron main_list">
			<li class="mui-table-view-cell">
				<a class="mui-navigate-right" href="javascript:void(0);" id="cp">
					<img src="images/icon4.png" />
					<h2>一个账号可交易17个品种</h2>
					<p>交易手续费：<i id="cp_tranfee">¥19.5/单边</i>起</p>
					<p class="buttomP"><label>交易时间：</label><span>09:05-23:55</span></p>
					
				</a>
			</li>
			<!--<li class="mui-table-view-cell">
				<a class="mui-navigate-right" href="javascript:void(0);" id="cn">
						<img src="images/icon1.png" />
						<h2>A股行情风向标</h2>
						<p>交易手续费：<i id="cn_tranfee">¥0/单边</i></p>
						<p class="buttomP"><label>交易时间：</label><span>9:05-16:30,17:05-02:00</span></p>	
				</a>
			</li>
			<li class="mui-table-view-cell">
				<a class="mui-navigate-right" href="javascript:void(0);" id="hsi">
					<img src="images/icon2.png" />
					<h2>港版IF 全网最低手续费</h2>
					<p>交易手续费：<i id="hsi_tranfee">¥0/单边</i></p>
					<p class="buttomP"><label>交易时间：</label><span>09:20-11:55,13:05-16:25,17:20-23:40</span></p>	
				</a>
			</li>
			<li class="mui-table-view-cell">
				<a class="mui-navigate-right" href="javascript:void(0);" id="cl">
						<img src="images/icon3.png" />
					<h2>全天候交易 夜盘行情更好</h2>
					<p>交易手续费：<i id="cl_tranfee">¥0/单边</i></p>
					<p class="buttomP"><label>交易时间：</label><span>09:05-02:00</span></p>
				</a>
			</li>-->
		</ul>
	</div>
</body>
<script src="js/jquery-1.11.3.js"></script>
	<script type="text/javascript" charset="utf-8">	
	
		mui.init({
				swipeBack:true //启用右滑关闭功能
		});
		tzdr.online();
			mui.plusReady(function(){ 
  			tzdr.init.initHearListener();
  			var dataUrl={
  				home:"home.html",
  				account:"tzdr/account/account.html",
  				accountno:"tzdr/account/accountno.html",
  				listrg:"tzdr/future/listrg.html",
  				quotationMain:"tzdr/quotation/quotationMain.html",
  				information: "tzdr/information/information.html"
  			}
  			initBottom(dataUrl);
  			var paramUrl={
				url:"tzdr/login/login.html"
			}
			document.getElementById("toNews").addEventListener("tap",function(){
			    document.getElementById("newsimg").setAttribute("src","images/news.png"); 
				mui.openWindow("tzdr/news/newslist.html");
			});
			document.getElementById("cp").addEventListener("tap",function(){
				mui.openWindow("tzdr/future/cp.html","cp"); 
			});
			/*document.getElementById("cn").addEventListener("tap",function(){
				mui.openWindow("tzdr/future/cn.html","cn");
			});
			document.getElementById("hsi").addEventListener("tap",function(){
				mui.openWindow("tzdr/future/hsi.html","hsi"); 
			});
			document.getElementById("cl").addEventListener("tap",function(){
				mui.openWindow("tzdr/future/cl.html","cl");
			});*/
			//获取手续费
			setTranfees();
			/** 
			 * banner 至少6张最好  
			 */
			//获取banner图片
			var imgId=[];
			mui.app_request('banner/list',{
				"type": 9
			},
				function(result){
					var bannerLen = result.data.bannerList == null ? 0 : result.data.bannerList.length;
					if (bannerLen>0){ 
						var  banner_content='';
						var indicator_content='';
						for (var i=0;i<bannerLen;i++){ 
							
							if (i==0){
								banner_content +=addBanner(result.data.bannerList[bannerLen-1],true);
								indicator_content+='<div class="mui-indicator mui-active"></div>';
							}else
							{
								indicator_content+='<div class="mui-indicator"></div>';
							}  
							 
							banner_content +=addBanner(result.data.bannerList[i]); 
							
							if (i==(bannerLen-1)){ 
								banner_content +=addBanner(result.data.bannerList[0],true); 
							}
							
						} 
						//alert(banner_content);
						document.getElementById('bannerloop').innerHTML=banner_content;
						document.getElementById('indicatorid').innerHTML=indicator_content; 
					}
					var slider = mui("#slider");  
					slider.slider({interval: 3000});
					
				},
				function(){
					
				},paramUrl
			);
			//新增banner 显示
			var timeNum=0;
			function addBanner(banner,firstend){
				var _html='';
				if (firstend){
					 _html='<div class="mui-slider-item mui-slider-item-duplicate" >';
				}
				else{ 
					 _html='<div class="mui-slider-item">';
				}
				_html +='<a class="id" href="javascript:void(0);" id="'+banner.linkUrl+'" data-id="'+timeNum+'"><img src="'+tzdr.constants.base_images_url+banner.imgPath+'" title=""/>';
				_html +='</a></div>';
				imgId.push(banner.linkUrl);
				timeNum++;
				return _html;
			}
			//监听banner点击事件
			var clickNum=0;
		mui("#bannerloop").on('tap','a',function(){		 
			//获取id
			var nid = this.getAttribute("id");
			if(clickNum<=imgId.length-1){
				var clickId = $(this).attr('data-id');
				nid=imgId[clickId];
				clickNum++;
			}
			var str="http";
			if(nid == "" || nid == null || nid.length == 0 ){
			}else if(nid.indexOf(str)==-1){
				mui.openWindow({url:"tzdr/news/news.html",id:nid,extras:{nid:nid}});
			}else{
				mui.openWindow({url:"tzdr/news/active.html",id:"active",extras:{nid:nid}});
			}
//			mui.openWindow({url:"tzdr/quotation/activity.html",id:"activity"});
////	    	mui.openWindow({url:"tzdr/news/news.html",id:nid,extras:{nid:nid}});
		});
		
			//获取新闻列表信息
			// 校验当日获取过新闻信息 如果当日已经加载过新闻不加在加载
			//alert(tzdr.dateUtil.getFormatDate() +"||"+tzdr.constants.is_load_news)
			//tzdr.cacheNews.clearData(tzdr.cacheNews.load_news_date);     
			if(tzdr.cacheNews.getData(tzdr.cacheNews.load_news_date)==tzdr.dateUtil.getFormatDate()){
				var cacheData = tzdr.cacheNews.getData(tzdr.cacheNews.news_data);
				 var cacheJsonData = JSON.parse(cacheData);  
				 mui.each(cacheJsonData,function(cacheIndex,cacheItem){
							   	 		if (!tzdr.cacheNews.isread(cacheItem.nid)){
							   	 			//TODO:新闻点亮 
							   		  		document.getElementById("newsimg").setAttribute("src","images/newson.png");
							   	 			return;
							   	 		}
				});
							   	 	
				return;
			} 
			else
			{//加载信息
				mui.app_request('news/list',{}, 
						function(result){
							var newsLen = result.data == null ? 0 : result.data.length;
							if (newsLen > 0){
								//alert(result.data);
								//tzdr.cacheNews.clearData(tzdr.cacheNews.news_data);   
							   //取出缓存中新闻列表  与 现有列表进行对比，如果有新的新闻则点亮新闻图标
							   //取缓存新闻
							   var cacheData = tzdr.cacheNews.getData(tzdr.cacheNews.news_data);
							  //alert(cacheData);  
							   if (mui.isnull(cacheData)){ 
							   	 // 表示缓存中没有数据，则直接标志新闻点亮  并存储数据
							  
							   	  tzdr.cacheNews.setData(tzdr.cacheNews.news_data,JSON.stringify(result.data));  
							   	  //TODO:新闻点亮
							   	  document.getElementById("newsimg").setAttribute("src","images/newson.png");
							   	 // 设置获取数据的时间
							   	  tzdr.cacheNews.setData(tzdr.cacheNews.load_news_date,tzdr.dateUtil.getFormatDate());
							   	  //alert(tzdr.cacheNews.getData(tzdr.cacheNews.news_data));  
							   	  return;
							   }  
							   
							   var cacheJsonData = JSON.parse(cacheData);  
							   var sameDataLen  = 0; // 缓存中与数据库中存在的数据数量长度
							   mui.each(result.data,function(index,item){
							   	 	mui.each(cacheJsonData,function(cacheIndex,cacheItem){
							   	 		if (item.nid==cacheItem.nid){
							   	 			sameDataLen +=1;
							   	 		}
								
							   	 	});
							   });
							   // 存储最新新闻
							  // tzdr.cacheNews.clearData(tzdr.cacheNews.news_data);   
							   tzdr.cacheNews.setData(tzdr.cacheNews.news_data,JSON.stringify(result.data));  
							  
							  //校验是否存在未读新闻
							  var hasNoRead = false;
							  mui.each(cacheJsonData,function(cacheIndex,cacheItem){
							   	 		if (!tzdr.cacheNews.isread(cacheItem.nid)){
							   	 			hasNoRead = true;
							   	 			return;
							   	 		}
							   	 	});
							   	 	
							   	 	
							   // 如果相同的数量 小于获取到的总数量则 有新新闻、
							   if (sameDataLen<newsLen || hasNoRead){
							   		//TODO:新闻点亮
							   		  document.getElementById("newsimg").setAttribute("src","images/newson.png");
							   }
							   // 设置获取数据的时间
							   tzdr.cacheNews.setData(tzdr.cacheNews.load_news_date,tzdr.dateUtil.getFormatDate());
							}
						},
						function(){
							
						},paramUrl
				);
			}
			
				function setTranfees(){
					mui.app_request("/ftrade/goods",{},function(result){
					if (result.data.isFtogetherActivityTime){
//							var ftogether_activity_show = plus.storage.getItem("ftogether_activity_show");
//							if (mui.isnull(ftogether_activity_show)){
//								document.getElementById("app_qj").style.display="block";
//								document.getElementById("app_tc").style.display="block";
								
								// 弹出框关闭
//								document.getElementById("closebtn").addEventListener('tap', function() {
//									closeActivityImg();
//								});
								// 跳转到合买页面
//								document.getElementById("partake").addEventListener('tap', function() {
//									closeActivityImg();
//									var p=plus.webview.getWebviewById("ftogether");
//									if(p){
//										mui.app_refresh('ftogether');  
//									}
//									mui.openWindow({url:mui.app_filePath("tzdr/buy/buy.html"),id:"ftogether"});
//								});
//							}
					}
				},function(result){
					mui.toast("系统繁忙，请刷新再试！");
					return;
				},paramUrl);
			}
		});	

</script>
</html>
